package com.cy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

//@Controller
//@ResponseBody
@RestController
@RequestMapping("/provider/")
//删除操作
public class RestProviderController {
    @DeleteMapping("{id}")
    public String doDeleteById(@PathVariable Long... id) {
        return Arrays.toString(id) + "is deleted";
    }

    @PostMapping
    public Map<String, Object> doCreate(@RequestBody Map<String, Object> map) {
        //....后续要将请求数据写入到数据库
        System.out.println("provider.map=" + map);
        Map<String, Object> responseMap = new HashMap<>();
        responseMap.put("status", 200);
        responseMap.put("message", "insert ok");
        return responseMap;
    }
//    @PostMapping
//    public String doCreare1(@RequestBody  Map<String,Object>map){
//        System.out.println("provider.map=" + map);
//        return "create ok";
//    }
    @PutMapping
    public Map<String, Object> doUpdate(@RequestBody Map<String, Object> map) {
        //....后续要将请求数据写入到数据库
        System.out.println("provider.map=" + map);
        Map<String, Object> responseMap = new HashMap<>();
        responseMap.put("status", 200);
        responseMap.put("message", "update ok");
        return responseMap;
    }
}
